/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package drivers;

import javax.swing.JFrame;
import transferObject.ProcessingImageTO;
import uk.co.caprica.vlcj.player.MediaPlayer;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;

/**
 *
 * @author Progresywny Maciek
 */
public class WebcamRSTP extends JFrame {

    public MediaPlayer mPlayer;
    private ProcessingImageTO oneFrame;
    private MediaPlayerFactory factory;

    public WebcamRSTP(String rstp) {
        System.setProperty("jna.library.path", "C:\\VLC");
        this.oneFrame = new ProcessingImageTO();
        this.factory = new MediaPlayerFactory("");
        this.mPlayer = factory.newEmbeddedMediaPlayer();
        this.mPlayer.startMedia(rstp);
    }

    public ProcessingImageTO getOneFrame() {
        oneFrame.setFrame(mPlayer.getSnapshot());
        return oneFrame;
    }

    public void closeCamera() {
        mPlayer.stop();
    }

    public void openCamera() {
        mPlayer.start();
    }

    public static void main(String[] args) throws InterruptedException {
        System.setProperty("jna.library.path", "C:\\VLC");
        WebcamRSTP wrstp = new WebcamRSTP("rtsp://192.168.100.104:8086");
        wrstp.getOneFrame();
    }
}
